<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="uiTags" prefix="ui"%>

<script type="text/javascript">
var roleManage={
		queryRole:function(){
			var params = new Object();
			params.name = getObject("name").val();
			params.code = getObject("code").val();
			asyRefreshDatagrid("rolemanageGrid","user/queryRole",params);
		},
		RoleAdd:function(){
			createResponse("新增角色", 800, 500, "user/enterRoleadd", "roleManage.queryRole()")
		},
		RoleEdit:function(){
			var row = getSelectedRow("rolemanageGrid");
			var roleid;
			if(row){
				roleid = row.roleid;
				createResponse("编辑角色",800,500,"user/enterRoleEdit?roleid=" + roleid,"roleManage.queryRole()");
			}else{
				showWarnAlert("请先选中后再操作！");
				return;
			}	
		},
		Roledelete:function(){
			var row = getSelectedRow("rolemanageGrid");
			var roleid;
			if(row){
				roleid = row.roleid;
				var params = new Object();
				params.roleid = roleid;
				ajaxRequest("user/deletRole",params);
				roleManage.queryuser();
				showWarnAlert("删除成功！");
			}else{
				showWarnAlert("请先选中后再操作！");
				return;
			}
		},
		enterRoleRightsGrant:function(){
			var row = getSelectedRow("rolemanageGrid");
			var roleid;
			if(row){
				roleid = row.roleid;
				createResponse("权限分配",800,700,"user/enterRoleRightsGrant?roleid=" + roleid,"");
			}else{
				showWarnAlert("请先选中后再操作！");
				return;
			}
		},
};
</script>
<ui:body>
	<div class="easyui-layout" style="width: 100%;height: 100%;" fit="true">
		<div data-options="region:'north',border:false" style="height: 110px">
			<ui:formtable id="rolemanageForm" formlabel="角色查询">
				<ui:textinput id="name" label="角色名称"  />
				<ui:textinput id="code" label="角色编码"  />
				<ui:buttons>
					<ui:button onclick="roleManage.queryRole()" value="查询" id="query" />
				</ui:buttons>
			</ui:formtable>
		</div>
		<div data-options="region:'center',border:false" style="overflow: hidden;" >
			<ui:datagrid id="rolemanageGrid" title="角色信息">
				<ui:dgtoolbar exportflag="true">
					<ui:button onclick="roleManage.RoleAdd()" value="新增" icon="icon-add" />
					<ui:button onclick="roleManage.RoleEdit()" value="编辑"  icon="icon-mini-edit" />
					<ui:button onclick="roleManage.Roledelete()" value="删除"  icon="icon-remove" />
					<ui:button onclick="roleManage.enterRoleRightsGrant()" value="权限分配"  icon="icon-user-config" />
				</ui:dgtoolbar>
				<ui:columntext  filed="roleid" text="" hidden="true"/>
				<ui:columntext text="角色名称" filed="name"/>
				<ui:columntext text="角色编码" filed="code" />
			</ui:datagrid>
		</div>
	</div>
</ui:body>